"""
两个线程同时访问同一个GPIO，似乎没啥大问题。读取红外的信号也是准确的。
"""

from machine import Pin
from time import sleep
import _thread


def thread_fun():
    pin = Pin(8, Pin.IN, Pin.PULL_DOWN)
    while True:
        print(f'Thread Value: {pin.value()}')
        sleep(1)
        
_thread.start_new_thread(thread_fun, ())


pin = Pin(8, Pin.IN, Pin.PULL_DOWN)
while True:
    print(f'Main Value: {pin.value()}')
    sleep(1)